/* eslint-disable no-shadow */
export function count({ search }) {
  return RSocket.rr({
    route: 'cbv.company.prices.count',
    args: { search },
  });
}

export function search({ search, pg }) {
  return RSocket.rs({
    route: 'cbv.company.prices',
    args: { search, pg },
  });
}

export function get(id) {
  return RSocket.rr({
    route: `cbv.company.prices.${id}`,
  });
}

export function update(price) {
  return RSocket.rr({
    route: 'cbv.company.prices.update',
    data: price,
  });
}

export function create(price) {
  const { isReturn, ...data } = price;
  return RSocket.rr({
    route: 'cbv.company.prices.create',
    args: isReturn === true ? { isReturn } : { isReturn: false },
    data,
  });
}

export function remove(id) {
  return RSocket.rr({
    route: `cbv.company.prices.${id}.delete`,
  });
}

/**
 * 获取存在的线路，用于查重
 * @param {{
    companyId: string,
    priceType: number,
    startMainArea: string,
    endMainArea: string,
    startMinorAreas: string[],
    endMinorAreas: string[],
    ports: string[],
  }} search 查询参数
 */
export function existingLines(search) {
  return RSocket.rs({
    route: 'cbv.company.prices.uniqueness',
    args: { search },
  });
}

/**
 * 获取所有区域和站点
 */
export function allItems() {
  return RSocket.rs({
    route: 'dicts.region.items.all',
  });
}

/**
 * @description 获取公司
 * @param {*} args 参数
 * @returns array
 */
export function getCompany({ search, pg }) {
  return RSocket.rs({
    route: 'companys',
    args: { search, pg },
  });
}


/**
 * 复制承运商线路
 */
export function cbvCompanyPriceCopy(data) {
  return RSocket.rr({
    route: 'cbv.company.prices.copy',
    data: { ...data },
  });
}

/**
 * ### 获取指定条件对应的价格列表
 */
export function companyConsolePrice(data) {
  return RSocket.rs({
    route: 'cbv.company.prices.console.price',
    data: { ...data },
  });
}

/**
 * 根据不同方向查询专线站点信息
 */
export function getScRegions(args) {
  return RSocket.rs({
    route: 'stations.shuttle',
    args: {
      search: {
        ...args,
      },
      pg: {
        size: 999,
        page: 0,
      },
    },
  });
}

/**
 * 按开始城市匹配站点
 * @param {*} data
 * @returns
 */
export function getScStation(data) {
  return RSocket.rs({
    route: 'prices.get.sc.station',
    data,
  });
}

/**
 * 搜索城市
 * @param {*} data
 * @returns
 */
export function getScCity(args) {
  return RSocket.rs({
    route: 'prices.get.sc.city',
    args,
  });
}
